// 通过cookie存储用户数据
// 引入cookie插件
import Cookies from 'js-cookie';
// 添加cookie
export function setUserCookie(info) {
  // 将对象数据变化成数组数据
  const arr = Object.entries(info);
  for (let i = 0; i < arr.length; i += 1) {
    // 向cookie中加入数据
    Cookies.set(arr[i][0], arr[i][1]);
  }
  return true;
}
// 获取cookie
export function getUserCookie() {
  return {
    username: Cookies.get('username'),
    appkey: Cookies.get('appkey'),
    role: Cookies.get('role'),
    email: Cookies.get('email'),
  };
}
// 删除cookie
export function removeUserCookie() {
  // 挨个删除每一条cookie
  Cookies.remove('username');
  Cookies.remove('appkey');
  Cookies.remove('role');
  Cookies.remove('email');
  return true;
}
